<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>建设单位注册</title>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta http-equiv="Expires" CONTENT="0">
    <meta http-equiv="Cache-Control" content="no-siteapp,no-transform,no-store, no-cache, must-revalidate">
    <meta http-equiv="Pragma" content="no-cache">
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon"/>
    <link rel="stylesheet" href="/static/css/font.css">
    <link rel="stylesheet" href="/static/css/weadmin.css">
    <script type="text/javascript" src="/lib/layui/layui.js" charset="utf-8"></script>
    <link rel="stylesheet" href="/static/css/buildUnit/common.css">
    <style>
        body {
            height: auto;
        }

        .content {
            padding: 20px;
            padding-bottom: 50px;
        }

        .layui-disabled {
            color: #aaa !important;
        }

        .personInfo {
            display: none;
        }

        .layui-form-checkbox[lay-skin=primary] span {
            color: #3366CC;
        }

        .footer {
            position: fixed;
            width: 100%;
            bottom: 0;
            text-align: center;
            background-color: #fff;
            padding: 10px 0;
        }
    </style>
</head>
<body>
<div class="content" style="width: 900px;">
    <!--机构信息-->
    <form class="layui-form layui-form-pane" action="" lay-filter="example">
        <table class="layui-table v-table">
            <tbody>
            <tr>
                <td class="th8 required">建设单位类型</td>
                <td colspan="3">
                    <input type="radio" name="orgPerson" value="2010" lay-filter="typeItem" title="企业（有营业执照）" checked>
                    <input type="radio" name="orgPerson" value="2030" lay-filter="typeItem" title="个人">
                </td>
            </tr>
            <tr>
                <td class="th8 required">单位名称</td>
                <td colspan="3">
                    <input type="text" name="orgName" required lay-verify="required" placeholder="请输入"
                           autocomplete="off"
                           class="layui-input">
                </td>
            </tr>
            <tr class="code">
                <td class="th8 required" style="color:red;">
                    <p style="color:#000;">组织机构代码</p>
                </td>
                <td class="orgCodeBox" colspan="3">
                    <input type="text" name="orgNo" required lay-verify="required" placeholder="请输入"
                           autocomplete="off"
                           class="layui-input orgCode">
                    <div class="tdBz" style="color:red;">
                        注：统一社会信用代码第9至第17位为该企业的组织机构代码，该号码为企业唯一标识，请如实填写
                    </div>
                </td>
            </tr>
            <tr class="jgInfo">
                <td class="th8 required">工商登记类型</td>
                <td colspan="3">
                    <select name="ecoType" id="orgRegistryType" lay-filter="orgRegistryType"
                            lay-verify="required">
                        <option value="">请选择</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td class="th8 required">企业法人</td>
                <td colspan="3">
                    <input type="text" name="comartiperson" lay-verify="required" placeholder="请输入"
                           autocomplete="off"
                           class="layui-input">
                </td>
            </tr>
            <tr>
                <td class="th8 required">法人联系方式</td>
                <td colspan="3">
                    <input type="text" name="comartiphone" lay-verify="required|phone" placeholder="请输入"
                           autocomplete="off"
                           class="layui-input vPhone">
                </td>
            </tr>
            <tr>
                <td class="th8 required">法人联系邮箱</td>
                <td colspan="3">
                    <input type="text" name="orgLinkMailbox" lay-verify="required|email" placeholder="请输入"
                           autocomplete="off"
                           class="layui-input vEmail">
                </td>
            </tr>
            <tr>
                <td class="th8 required">登录名称</td>
                <td colspan="3">
                    <input type="text" name="loginName" lay-verify="required|upass" placeholder=""
                           autocomplete="off"
                           class="layui-input loginName">
                </td>
            </tr>
            <tr>
                <td class="th8 required">登录密码</td>
                <td>
                    <input type="password" name="password" lay-verify="required|upass" placeholder=""
                           autocomplete="off"
                           class="layui-input password">
                </td>
                <td class="th8 required">确认密码</td>
                <td>
                    <input type="password" name="" lay-verify="required|upass" placeholder=""
                           autocomplete="off"
                           class="layui-input rePassword">
                </td>
            </tr>
            <tr>
                <td class="th8 required">资料上传</td>
                <td colspan="3">
                    <div class="fjBzBox">
                        <p><span>1</span>、单位有效证件（统一社会信用代码证、营业执照副本或事业单位法人证书等）→复印→盖章→扫描或拍照；</p>
                        <p><span>2</span>、联系人身份证明（身份证等）→证件正反面复印到一张A4纸→盖章（公章）→扫描或拍照；</p>
                        <p>注：照片完整、文字清晰可辨，照片格式为"jpg格式"或"png格式"，扫描分辨率100DPI即可，单张图片不要超过2M。</p>
                    </div>
                    <div>
                        <!--<iframe src="" frameborder="0" class="attachmentList" name="attachmentList" style="height:120px;"></iframe>-->
                    </div>
                </td>
            </tr>
            <tr>
                <td colspan="4" style="text-align: center;">
                    <input id="isAgree" type="checkbox" name="" title="我已经认真如实填写上述资料，并且对所填写的资料负责。" lay-skin="primary"
                           lay-filter="isAgree">
                </td>
            </tr>
            </tbody>
        </table>
        <div class="footer">
            <button class="demo1 layui-btn layui-btn-disabled layui-btn-normal" lay-filter="demo1" lay-submit
                    disabled="true">
                提交注册
            </button>
            <button onclick="cancel()" type="button" class="layui-btn">取消注册</button>
        </div>
    </form>
</div>
<script src="/static/js/main.js"></script>
<script type="text/javascript">
    layui.use(['jquery', 'form', 'configure', 'configureCom', 'selectFun', 'bluebird', 'jsDictFile'], function () {
        var form = layui.form;
        var configure = layui.configure;
        var jsDictFile = layui.jsDictFile;
        var configureCom = layui.configureCom;
        var selectFun = layui.selectFun;
        window.$ = layui.jquery;
        var typeItem = '2010';//注册类型 2010企业 2020临时 2030个人

        //工商登记类型
       /* $.each(jsDictFile.orgRegistryType, function (index, item) {
            selectFun.appendOptionTo($('form').find('select#orgRegistryType'), item.name, item.value, '');
        });*/

        configureCom.selectDataFun(configure.COMPANY_ECT_TYPE_CODE,'','.orgRegistryType');

       /* function changeIframe() {
            $('.attachmentList').attr('src', configureCom.nocache(configure.ATTA_LIST_HTML + '?checkType=36&type=add&dataId='));
        }

        changeIframe();*/

        form.render();

        //选择不同的注册类型
        form.on('radio(typeItem)', function (data) {
            typeItem = data.value;
            // 重置列表
            $('.layui-form')[0].reset();
            form.render();
            form.val("example", {typeItem: typeItem});
            if (typeItem == '2030') {//个人
                $('.code p').html('联系人身份证号');
                $('.tdBz').hide();
                $('.fjBzBox p:nth-child(1)').hide();
                $('.fjBzBox p:nth-child(2) span').html(1);
            } else {
                $('.code p').html('组织机构代码');
                $('.tdBz').show();
                $('.tdBz').html('注：统一社会信用代码第9至第17位为该企业的组织机构代码，该号码为企业唯一标识，请如实填写');
                $('.fjBzBox p:nth-child(1)').show();
                $('.fjBzBox p:nth-child(2) span').html(2);
            }
        });

        /*window.fjLoaded = function () {//附件列表渲染完毕重设附件列表序号
            if (window.hideTrNum == 1) {
                window.frames["attachmentList"].window.$('#attaList tr:nth-child(2) td').first().html(1);
            }
        };*/

        //是否同意提示信息
        form.on('checkbox(isAgree)', function (data) {
            var isAgree = data.elem.checked;//是否被选中，true或者false
            if (isAgree) {
                $('.demo1').attr('disabled', false).removeClass('layui-btn-disabled');
                form.render();
            } else {
                $('.demo1').attr('disabled', true).addClass('layui-btn-disabled');
                form.render();
            }
        });

        //保存机构信息
        form.on('submit(demo1)', function (data) {
            var data = data.field;
            // 如果是个人 验证身份证号
            if (data.typeItem == '2030') {
                var reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
                if (!reg.test(data.code)) {
                    var msg = '请输入正确的身份证号';
                    top.layer.msg(msg);
                    return false;
                }
            }

            if ($('.rePassword').val() != $('.password').val()) {
                var msg = '两次输入的密码不一致';
                top.layer.msg(msg);
                return false;
            }
            data.type = '1010';//建设单位
            console.log(data);
            configureCom.postDataAjax(configure.CONPANY_SIGN_REGISTER,data).then(function(res){
                console.log(res);
            });
            //获取附件信息
            /*window.frames["attachmentList"].window.getAttaList(function (result) {
                //判断必传
                if (typeItem == '2010') {//企业信息俩个必传
                    if (result.length < 2) {
                        configureCom.loadOff();
                        top.layer.msg('请上传附件');
                        return false;
                    }
                } else {//其他 一个必传
                    if (result.length < 1) {
                        configureCom.loadOff();
                        top.layer.msg('请上传附件');
                        return false;
                    }
                }
                data.dataAttachmentDTOList = [{
                    attachmentFileDTOList: result
                }];
                configureCom.postAjax(configure.ORGANIZATION_HTTP, JSON.stringify(data)).then(function (res) {
                    configureCom.loadOff();
                    if (res.code == 1) {
                        top.layer.msg('注册成功');
                        top.layer.close(window.popIndex);
                    } else {
                        top.layer.msg(res.msg);
                    }
                });
            });*/
            return false;
        });
    });

</script>
</body>
</html>
